<template>
  <div>js题</div>
</template>
<script setup>
var obj = {
  name: "张三",
  info: { age: 20 },
  getName: function () {
    console.log(this.name);
  },
};
console.log(123,obj);

const obj1=function cloneData(obj) {
    if (typeof obj !== 'object' || obj == null) {
        return obj
    }
    let result
    if (obj instanceof Array) {
        result = []
    } else {
        result = {}
    }
    for (let key in obj) {
        if (obj.hasOwnProperty(key)) {
            result[key] = cloneData(obj[key])
        }
    }
    return result
}
console.log(456,obj1(obj));



obj.info.age = 30
obj.name = '李四'
console.log(789,obj);
console.log(obj.getName())


</script>
<style scoped lang='scss'>
</style>